package osami.communication;

/**
 * Bluetooth-address class
 * 
 * @author osami
 *
 */
public class BluetoothAddress implements Address
{
	String iAddress;
	/**
	 * Basic constructor for BluetoothAddress
	 * @param aAddress
	 */
	public BluetoothAddress( String aAddress )
	{
		iAddress = aAddress;
	}
	
	/**
	 * Compares the address given to existing connections and returns the result as boolean
	 * 
	 * @param aAddress 
	 * @return Boolean
	 */
	public boolean equals( Address aAddress )
	{
		if (aAddress.getClass() == BluetoothLongAddress.class)
		{
			return iAddress.contentEquals( aAddress.toString().substring( 8, 20 ) );
		}

		return iAddress.contentEquals( aAddress.toString() );
	}
	
	/**
	 * returns the address as a string
	 * @return String
	 */
	public String toString()
	{
		return iAddress;
	}

	/**
	 * returns the hostname as a string
	 * @return String
	 */
	public String getHostName()
	{
		return iAddress;
	}
}
